﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Theme="SkinFile" Inherits="Nivdal.ViewDuplicateConnections" Title="Suspicious connections - nivdal.com!" Codebehind="ViewDuplicateConnections.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">   
    <div class="basic_element">
    <div class="red_title">
       <asp:Label ID="PageTitleLabel" runat="server" Text="User suspicious connections" CssClass="white_title"></asp:Label>
    </div>
    <div class="padding5">

        <asp:Label ID="TestedUserTitleLabel" runat="server" Text="Tested User: " SkinID="InfoLabel"></asp:Label>
        <asp:HyperLink ID="UserPageHyperlink" runat="server" SkinID="GreenTitleHyperLink"></asp:HyperLink>
        <br /><br />
        <asp:Label ID="UserDetailsTitleLabel" runat="server" SkinID="InfoLabel" Text="UserDetails"></asp:Label>
        <br />
        <asp:FormView ID="UserDetailsFormView" runat="server" DataSourceID="UserDetailsDS">
        <ItemTemplate>
            <table>
            <tr>
            <td>
                <asp:Label ID="LoginNameTitle" runat="server" Text="Login name" SkinID="InfoLabel"></asp:Label>
            </td>
            <td>
                <asp:Label ID="LoginName" runat="server" Text='<%# Eval("LoginName") %>' SkinID="GridLabel"></asp:Label>
                <asp:Image ID="IsCheaterImage" runat="server" ImageUrl='<%# (bool)Eval("IsCheater") ? "~/Images/Icons/players_red.jpg" : "~/Images/Icons/vi.png" %>'
                 ToolTip='<%# (bool)Eval("IsCheater") ? "Is suspected cheater" : "Is not suspected cheateer" %>' />
                <asp:Image ID="LockedImage" runat="server" ImageUrl="~/Images/Icons/ThreadClosed.png"
                 ToolTip="this user is locked out" Visible='<%# Eval("IsLockedOut") %>' />
            </td>
            </tr>
            <tr>
            <td>
                <asp:Label ID="PublicNameTitle" runat="server" Text="Public name" SkinID="InfoLabel"></asp:Label>
            </td>
            <td>
                <asp:Label ID="PublicName" runat="server" Text='<%# Eval("Username") %>' SkinID="GridLabel"></asp:Label>
            </td>
            </tr>
            <tr>
            <td>
                <asp:Label ID="EmailTitle" runat="server" Text="email" SkinID="InfoLabel"></asp:Label>
            </td>
            <td>
                <asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' SkinID="GridLabel"></asp:Label>
            </td>
            </tr>
            </table>
        

        </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="UserDetailsDS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
         SelectCommand="Nivdal_GetUserDetails" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <br /><br />

        <asp:Panel ID="ChatsPanel" runat="server" Width="200">
            <asp:Label ID="OpenChatsTitleLabel" runat="server" SkinID="InfoLabel" Text="Open chats with:"></asp:Label>
            <br />
            <asp:Gridview ID="ChatsGrid" runat="server" SkinID="Professional" DataSourceID="ChatsDataSource" 
             AllowPaging="false" AutoGenerateColumns="false">
             <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="UserLink" runat="server" SkinID="GreenTitleHyperLink" Text='<%# Eval("UserName") %>'
                         NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("UserId") %>' ></asp:HyperLink>
                     
                         <asp:ImageButton ID="IsActiveImageButton" runat="server" ImageUrl='<%# (bool)Eval("IsInRoom") ? "~/Images/Icons/vi.png" : "~/Images/Icons/posdelete.jpg" %>'
                          ToolTip='<%# (bool)Eval("IsInRoom") ? "Is in the room" : "Is not in the room" %>' PostBackUrl='<%# "~/ChatroomDetails.aspx?Id=" + Eval("ChatroomId") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
             </Columns>
             <EmptyDataTemplate>
                <asp:Label ID="NoChatsLabel" runat="server" SkinID="GridLabel" Text="No active chats"></asp:Label>
             </EmptyDataTemplate>
             </asp:Gridview>
             <asp:SqlDataSource ID="ChatsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                 SelectCommand="Nivdal_GetOpenChatRoomsForUser" SelectCommandType="StoredProcedure">
                </asp:SqlDataSource>
            <br /><br />
        </asp:Panel>
        <asp:Label ID="UserLoginsTitleLabel" runat="server" Text="User logins" SkinID="InfoLabel"></asp:Label>
        <br />
        <div style="width:70%;">
        <asp:GridView ID="UserLoginsGridview" runat="server" SkinID="Professional" AllowPaging="true" DataSourceID="UserLoginsDS" 
          PageSize="10" AutoGenerateColumns="false">
            <PagerSettings FirstPageText="<%$ Resources:Resource, FirstPage %>" LastPageText="<%$ Resources:Resource, LastPage %>"
                Mode="NumericFirstLast" PageButtonCount="5" Position="TopAndBottom" />
            <PagerStyle CssClass="pagination" HorizontalAlign="Center" /> 
            <RowStyle CssClass="NewsItemStyle" />
            <Columns>
                <asp:BoundField DataField="Date" HeaderText="Date" />
                <asp:TemplateField HeaderText="IP">
                <ItemTemplate>
                    <asp:HyperLink ID="IPLocationHyperlink" runat="server" NavigateUrl='<%# "http://www.ip2location.com/" + Eval("IP") %>' Target="_blank"
                     Text='<%# Eval("IP") %>'></asp:HyperLink>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="IPCountry">
                <ItemTemplate>
                    <asp:Label ID="CountryLabel" runat="server" Text='<%# GetCountryByIP(Eval("IP")) %>'></asp:Label>
                </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        </div>

        <asp:SqlDataSource ID="UserLoginsDS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
         SelectCommand="Nivdal_GetAllUserLogins" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <br /><br />
        <asp:Label ID="DuplicateConnections" runat="server" Text="Connected from the same IP addresses:" SkinID="InfoLabel"></asp:Label>
        <br />
        <asp:GridView ID="GridView1" runat="server" DataSourceID="SimilarConnectionsDataSource" SkinID="Professional"
         AutoGenerateColumns="false" AllowPaging="true" PageSize="20">
            <EmptyDataTemplate>
                <asp:Label ID="NothingToReportLabel" runat="server" SkinID="GridLabel"
                Text="No other users recently connected from the same IP address as this user"></asp:Label>
            </EmptyDataTemplate>
            <Columns>
                <asp:TemplateField HeaderText="User">
                    <ItemTemplate>
                        <asp:HyperLink ID="OtherUserHyperlink" runat="server" NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("UserId") %>'
                         Text='<%# Eval("UserName") %>' SkinID="GreenTitleHyperLink"></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="IP address">
                    <ItemTemplate>
                        <asp:Label ID="IPLabel" runat="server" Text='<%# Eval("IP") %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Date">
                    <ItemTemplate>
                        <asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>            
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Transfers">
                    <ItemTemplate>
                        <asp:HiddenField ID="User1HiddenField" runat="server" Value='<%# Eval("UserId") %>' />
                        <asp:HiddenField ID="User2HiddenField" runat="server" Value='<%# Eval("TestedUser") %>' />
                        <asp:ListView ID="TransfersListView" runat="server" DataSourceID="TransfersDataSource">
                            <LayoutTemplate>
                                <asp:Label ID="TransfersTitleLabel" runat="server" Text="Transfers between the two teams:" SkinID="InfoLabel"></asp:Label>
                                <br />
                                <asp:Label ID="itemplaceholder" runat="server"></asp:Label>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <asp:HyperLink ID="PlayerHyperlink" runat="server" NavigateUrl='<%# "~/Player.aspx?Id=" + Eval("PlayerId") %>'
                                 Text='<%# Eval("PlayerName") %>' SkinID="GreenTitleHyperLink"></asp:HyperLink>
                                <asp:Label ID="OnLabel" runat="server" Text=" on " SkinID="GridLabel"></asp:Label>
                                <asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' SkinID="GridLabel"></asp:Label>
                                <asp:Label ID="ForLabel" runat="server" Text=" for " SkinID="GridLabel"></asp:Label>
                                <asp:Label ID="SumLabel" runat="server" Text='<%# Eval("TransferSum") %>' SkinID="GridLabel"></asp:Label>
                                <asp:Label ID="FromLabel" runat="server" Text=" from " SkinID="GridLabel"></asp:Label>
                                <asp:HyperLink ID="SellerHyperlink" runat="server" NavigateUrl='<%# "~/TeamHomePage.aspx?TeamId=" + Eval("SellerId") %>'
                                 SkinID="GreenTitleHyperLink" Text='<%# Eval("SellerName") %>'></asp:HyperLink>                                
                                <asp:Label ID="ToLabel" runat="server" Text=" to " SkinID="GridLabel"></asp:Label>
                                <asp:HyperLink ID="BuyerHyperlink" runat="server" NavigateUrl='<%# "~/TeamHomePage.aspx?TeamId=" + Eval("BuyerId") %>'
                                 SkinID="GreenTitleHyperLink" Text='<%# Eval("BuyerName") %>'></asp:HyperLink> 
                            </ItemTemplate>
                            <ItemSeparatorTemplate>
                                <hr />
                            </ItemSeparatorTemplate>
                            <EmptyDataTemplate>
                                <asp:Label ID="NoTransfersBetweenTeams" runat="server" Text="No transfers between the two teams" SkinID="GridLabel"></asp:Label>
                            </EmptyDataTemplate>
                        </asp:ListView>
                                        
                        <asp:SqlDataSource ID="TransfersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                         SelectCommand="Nivdal_GetTransfersBetweenTwoUsers" SelectCommandType="StoredProcedure">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="User1HiddenField" Name="User1" PropertyName="Value" Type="String" />
                                <asp:ControlParameter ControlID="User2HiddenField" Name="User2" PropertyName="Value" Type="String" />
                            </SelectParameters>
                        </asp:SqlDataSource>                    
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SimilarConnectionsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
         SelectCommand="Nivdal_ShowSimilarConnectionsForUser" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>

        <br /><br />
        <asp:Label ID="SuspiciousTransfersTitleLabel" runat="server" Text="Suspicous transfers: " SkinID="InfoLabel">
        </asp:Label>
        <asp:GridView ID="SuspiciousTransfersGrid" runat="server" AutoGenerateColumns="false" AllowPaging="false"
         SkinID="Professional" DataSourceID="SuspiciousTransfersDataSource">
            <EmptyDataTemplate>
                <asp:Label ID="NoSuspTransfers" runat="server" Text="No suspitious transfers for this user" SkinID="GridLabel"></asp:Label>
            </EmptyDataTemplate>
            <Columns>
                <asp:TemplateField HeaderText="Dates">
                    <ItemTemplate>
                        <asp:Label ID="CreateDateLabel" runat="server" Text='<%# "Create date: " + Eval("DateCreated") %>' SkinID="GridLabel"></asp:Label>
                        <br />
                        <asp:Label ID="TreatedDateLabel" runat="server" Text='<%# "Treated date: " + Eval("TreatedDate") %>' SkinID="GridLabel"></asp:Label>
                        <br />
                        <asp:Label ID="PostponedTillLabel" runat="server" Text='<%# "Postponed till: " + Eval("PostponedTill") %>' SkinID="GridLabel"></asp:Label>                    
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Player">
                    <ItemTemplate>
                        <asp:HyperLink ID="PlayerLink" runat="server" Text='<%# Eval("PlayerName") %>' SkinID="GreenTitleHyperLink"
                         NavigateUrl='<%# "~/Player.aspx?Id=" + Eval("PlayerId") %>'></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Users">
                    <ItemTemplate>
                        <asp:Label ID="SellerTitleLabel" runat="server" SkinID="InfoLabel" Text="Seller: "></asp:Label>
                        <asp:HyperLink ID="SellerHyperlink" runat="server" SkinID="GreenTitleHyperLink"
                         Text='<%# Eval("SellerName") %>' NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("SuspectedSeller") %>'></asp:HyperLink>
                        <br />
                        <asp:Label ID="Buyer1TitleLabel" runat="server" SkinID="InfoLabel" Text="Buyer 1: "></asp:Label>
                        <asp:HyperLink ID="Buyer1Hyperlink" runat="server" SkinID="GreenTitleHyperLink"
                         Text='<%# Eval("Buyer1Name") %>' NavigateUrl='<%# "~/UserPage.aspx?Id=" +  Eval("SuspectedBuyer1") %>'></asp:HyperLink>
                        <br />
                        <asp:Label ID="Buyer2TitleLabel" runat="server" SkinID="InfoLabel" Text="Buyer 2: "></asp:Label>
                        <asp:HyperLink ID="Buyer2Hyperlink" runat="server" SkinID="GreenTitleHyperLink"
                         Text='<%# Eval("Buyer2Name") %>' NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("SuspectedBuyer2") %>'></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Reasons">
                    <ItemTemplate>
                        <asp:Label ID="IPReasonLabel" runat="server" SkinID="GridLabel" Text="IP" Visible='<%# Eval("SubmitReasonIP") %>'></asp:Label>
                        &nbsp;
                        <asp:Label ID="SumReasonLabel" runat="server" SkinID="GridLabel" Text="Sum" Visible='<%# Eval("SubmitReasonSum") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Actions">
                    <ItemTemplate>
                        <asp:Panel ID="TreatedPanel" runat="server" Visible='<%# Eval("Treated") %>' >
                            <asp:Image ID="SCheater" runat="server" 
                            ImageUrl='<%# (bool)Eval("Treated") && (bool)Eval("SMarkedCheater") ? "~/Images/Icons/RedCircle.png" : "~/Images/Icons/GreenCircle.png" %>'
                            ToolTip='<%# (bool)Eval("Treated") && (bool)Eval("SMarkedCheater") ? "Seller marked as cheater" : "Seller was not marked as cheater" %>' />
                             <asp:Image ID="B1Cheater" runat="server" 
                            ImageUrl='<%# (bool)Eval("Treated") && (bool)Eval("B1MarkedCheater") ? "~/Images/Icons/RedCircle.png" : "~/Images/Icons/GreenCircle.png" %>'
                            ToolTip='<%# (bool)Eval("Treated") && (bool)Eval("B1MarkedCheater") ? "Seller marked as cheater" : "Seller was not marked as cheater" %>' />
                            <asp:Image ID="B2Cheater" runat="server" 
                            ImageUrl='<%# (bool)Eval("Treated") && (bool)Eval("B2MarkedCheater") ? "~/Images/Icons/RedCircle.png" : "~/Images/Icons/GreenCircle.png" %>'
                            ToolTip='<%# (bool)Eval("Treated") && (bool)Eval("B2MarkedCheater") ? "Seller marked as cheater" : "Seller was not marked as cheater" %>' />
                            <asp:HyperLink ID="TreatedByLink" runat="server" NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("TreatedBy") %>'
                             Text='<%# Eval("GMName") %>' SkinID="GreenTitleHyperLink"></asp:HyperLink>
                        </asp:Panel>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Note">
                    <ItemTemplate>
                        <asp:Label ID="NoteLabel" runat="server" SkinID="GridLabel" Text='<%# Eval("Note") %>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
         </asp:GridView>
         <asp:SqlDataSource ID="SuspiciousTransfersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
         SelectCommand="Nivdal_GetUserSuspiciousTransferReports" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
    </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageNamePlaceHolder" Runat="Server">
    <asp:Label ID="PageNameLabel" runat="server" Text="User suspicious connections" CssClass="white_title"></asp:Label>
</asp:Content>

